home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume6 / rpc2 / part05 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  52.7 KB

  1. Subject:  v06i093:  Sun RPC Source (rpc2), Part05/11
  2. Newsgroups: mod.sources
  3. Approved: rs@mirror.UUCP
  4.  
  5. Submitted by: cca!SUN.COM!marks (Mark Stein)
  6. Mod.sources: Volume 6, Issue 93
  7. Archive-name: rpc2/Part05
  8.  
  9. [  I have done nothing other than verify that the files unpack ok.  --r$  ]
  10.  
  11. Sun RPC source (part 5 of 11).  This software package contains code
  12. and documentation for Revision 3.0 of the Sun Remote Procedure Call
  13. library.  In addition, a beta version of the XDR/RPC protocol compiler
  14. is included.  Comments about this latest release may be mailed to
  15. sun!rpc or rpc@sun.com.
  16.  
  17. Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  18. unrestricted use provided that this legend is included on all tape
  19. media and as a part of the software program in whole or part.  Users
  20. may copy or modify Sun RPC without charge, but are not authorized to
  21. license or distribute it to anyone else except as part of a product or
  22. program developed by the user.
  23.  
  24. - - - - - - - - - C U T - H E R E - - - - - - - - - - - - - - - - - -
  25. #! /bin/sh
  26. # This is a shell archive, meaning:
  27. # 1. Remove everything above the #! /bin/sh line.
  28. # 2. Save the resulting text in a file.
  29. # 3. Execute the file with /bin/sh (not csh) to create:
  30. #    rpc/rpclib/auth.h
  31. #    rpc/rpclib/auth_unix.h
  32. #    rpc/rpclib/clnt.h
  33. #    rpc/rpclib/pmap_clnt.h
  34. #    rpc/rpclib/pmap_prot.h
  35. #    rpc/rpclib/rpc.h
  36. #    rpc/rpclib/rpc_msg.h
  37. #    rpc/rpclib/svc.h
  38. #    rpc/rpclib/svc_auth.h
  39. #    rpc/rpclib/types.h
  40. #    rpc/rpclib/xdr.h
  41. # This archive created: Mon Jul 14 16:55:13 1986
  42. export PATH; PATH=/bin:/usr/bin:$PATH
  43. for d in rpc rpc/doc rpc/rpclib rpc/tools rpc/toys rpc/rpclib/profiled rpc/rpcgen rpc/rpcgen/test
  44. do
  45.     if test ! -d $d
  46.     then
  47.         echo "shar: Making directory $d"
  48.         mkdir $d
  49.         chmod 755 $d
  50.     fi
  51. done
  52. echo shar: "extracting 'rpc/rpclib/auth.h'" '(4399 characters)'
  53. if test -f 'rpc/rpclib/auth.h'
  54. then
  55.     echo shar: "will not over-write existing file 'rpc/rpclib/auth.h'"
  56. else
  57. sed 's/^X//' << \SHAR_EOF > 'rpc/rpclib/auth.h'
  58. X/*
  59. X * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  60. X * unrestricted use provided that this legend is included on all tape
  61. X * media and as a part of the software program in whole or part.  Users
  62. X * may copy or modify Sun RPC without charge, but are not authorized
  63. X * to license or distribute it to anyone else except as part of a product or
  64. X * program developed by the user.
  65. X * 
  66. X * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  67. X * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  68. X * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  69. X * 
  70. X * Sun RPC is provided with no support and without any obligation on the
  71. X * part of Sun Microsystems, Inc. to assist in its use, correction,
  72. X * modification or enhancement.
  73. X * 
  74. X * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  75. X * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  76. X * OR ANY PART THEREOF.
  77. X * 
  78. X * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  79. X * or profits or other special, indirect and consequential damages, even if
  80. X * Sun has been advised of the possibility of such damages.
  81. X * 
  82. X * Sun Microsystems, Inc.
  83. X * 2550 Garcia Avenue
  84. X * Mountain View, California  94043
  85. X */
  86. X/*      @(#)auth.h 1.1 86/02/03 SMI      */
  87. X
  88. X/*
  89. X * auth.h, Authentication interface.
  90. X *
  91. X * Copyright (C) 1984, Sun Microsystems, Inc.
  92. X *
  93. X * The data structures are completely opaque to the client.  The client
  94. X * is required to pass a AUTH * to routines that create rpc
  95. X * "sessions".
  96. X */
  97. X
  98. X
  99. X#define MAX_AUTH_BYTES    400
  100. X
  101. X
  102. X/*
  103. X * Status returned from authentication check
  104. X */
  105. Xenum auth_stat {
  106. X    AUTH_OK=0,
  107. X    /*
  108. X     * failed at remote end
  109. X     */
  110. X    AUTH_BADCRED=1,            /* bogus credentials (seal broken) */
  111. X    AUTH_REJECTEDCRED=2,        /* client should begin new session */
  112. X    AUTH_BADVERF=3,            /* bogus verifier (seal broken) */
  113. X    AUTH_REJECTEDVERF=4,        /* verifier expired or was replayed */
  114. X    AUTH_TOOWEAK=5,            /* rejected due to security reasons */
  115. X    /*
  116. X     * failed locally
  117. X    */
  118. X    AUTH_INVALIDRESP=6,        /* bogus response verifier */
  119. X    AUTH_FAILED=7            /* some unknown reason */
  120. X};
  121. X
  122. X
  123. Xunion des_block {
  124. X    struct {
  125. X        u_long high;
  126. X        u_long low;
  127. X    } key;
  128. X    char c[8];
  129. X};
  130. X
  131. X
  132. X/*
  133. X * Authentication info.  Opaque to client.
  134. X */
  135. Xstruct opaque_auth {
  136. X    enum_t    oa_flavor;        /* flavor of auth */
  137. X    caddr_t    oa_base;        /* address of more auth stuff */
  138. X    u_int    oa_length;        /* not to exceed MAX_AUTH_BYTES */
  139. X};
  140. X
  141. X
  142. X/*
  143. X * Auth handle, interface to client side authenticators.
  144. X */
  145. Xtypedef struct {
  146. X    struct    opaque_auth    ah_cred;
  147. X    struct    opaque_auth    ah_verf;
  148. X    union    des_block    ah_key;
  149. X    struct auth_ops {
  150. X        void    (*ah_nextverf)();
  151. X        int    (*ah_marshal)();    /* nextverf & serialize */
  152. X        int    (*ah_validate)();    /* validate varifier */
  153. X        int    (*ah_refresh)();    /* refresh credentials */
  154. X        void    (*ah_destroy)();    /* destroy this structure */
  155. X    } *ah_ops;
  156. X    caddr_t ah_private;
  157. X} AUTH;
  158. X
  159. X
  160. X/*
  161. X * Authentication ops.
  162. X * The ops and the auth handle provide the interface to the authenticators.
  163. X *
  164. X * AUTH    *auth;
  165. X * XDR    *xdrs;
  166. X * struct opaque_auth verf;
  167. X */
  168. X#define AUTH_NEXTVERF(auth)        \
  169. X        ((*((auth)->ah_ops->ah_nextverf))(auth))
  170. X#define auth_nextverf(auth)        \
  171. X        ((*((auth)->ah_ops->ah_nextverf))(auth))
  172. X
  173. X#define AUTH_MARSHALL(auth, xdrs)    \
  174. X        ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
  175. X#define auth_marshall(auth, xdrs)    \
  176. X        ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
  177. X
  178. X#define AUTH_VALIDATE(auth, verfp)    \
  179. X        ((*((auth)->ah_ops->ah_validate))((auth), verfp))
  180. X#define auth_validate(auth, verfp)    \
  181. X        ((*((auth)->ah_ops->ah_validate))((auth), verfp))
  182. X
  183. X#define AUTH_REFRESH(auth)        \
  184. X        ((*((auth)->ah_ops->ah_refresh))(auth))
  185. X#define auth_refresh(auth)        \
  186. X        ((*((auth)->ah_ops->ah_refresh))(auth))
  187. X
  188. X#define AUTH_DESTROY(auth)        \
  189. X        ((*((auth)->ah_ops->ah_destroy))(auth))
  190. X#define auth_destroy(auth)        \
  191. X        ((*((auth)->ah_ops->ah_destroy))(auth))
  192. X
  193. X
  194. Xextern struct opaque_auth _null_auth;
  195. X
  196. X
  197. X/*
  198. X * These are the various implementations of client side authenticators.
  199. X */
  200. X
  201. X/*
  202. X * Unix style authentication
  203. X * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
  204. X *    char *machname;
  205. X *    int uid;
  206. X *    int gid;
  207. X *    int len;
  208. X *    int *aup_gids;
  209. X */
  210. Xextern AUTH *authunix_create();
  211. Xextern AUTH *authunix_create_default();    /* takes no parameters */
  212. Xextern AUTH *authnone_create();        /* takes no parameters */
  213. X
  214. X#define    AUTH_NULL    0
  215. X#define    AUTH_UNIX    1        /* unix style (uid, gids) */
  216. X#define    AUTH_SHORT    2        /* short hand unix style */
  217. SHAR_EOF
  218. if test 4399 -ne "`wc -c < 'rpc/rpclib/auth.h'`"
  219. then
  220.     echo shar: "error transmitting 'rpc/rpclib/auth.h'" '(should have been 4399 characters)'
  221. fi
  222. chmod 444 'rpc/rpclib/auth.h'
  223. fi
  224. echo shar: "extracting 'rpc/rpclib/auth_unix.h'" '(2343 characters)'
  225. if test -f 'rpc/rpclib/auth_unix.h'
  226. then
  227.     echo shar: "will not over-write existing file 'rpc/rpclib/auth_unix.h'"
  228. else
  229. sed 's/^X//' << \SHAR_EOF > 'rpc/rpclib/auth_unix.h'
  230. X/*
  231. X * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  232. X * unrestricted use provided that this legend is included on all tape
  233. X * media and as a part of the software program in whole or part.  Users
  234. X * may copy or modify Sun RPC without charge, but are not authorized
  235. X * to license or distribute it to anyone else except as part of a product or
  236. X * program developed by the user.
  237. X * 
  238. X * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  239. X * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  240. X * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  241. X * 
  242. X * Sun RPC is provided with no support and without any obligation on the
  243. X * part of Sun Microsystems, Inc. to assist in its use, correction,
  244. X * modification or enhancement.
  245. X * 
  246. X * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  247. X * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  248. X * OR ANY PART THEREOF.
  249. X * 
  250. X * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  251. X * or profits or other special, indirect and consequential damages, even if
  252. X * Sun has been advised of the possibility of such damages.
  253. X * 
  254. X * Sun Microsystems, Inc.
  255. X * 2550 Garcia Avenue
  256. X * Mountain View, California  94043
  257. X */
  258. X/*      @(#)auth_unix.h 1.1 86/02/03 SMI      */
  259. X
  260. X/*
  261. X * auth_unix.h, Protocol for UNIX style authentication parameters for RPC
  262. X *
  263. X * Copyright (C) 1984, Sun Microsystems, Inc.
  264. X */
  265. X
  266. X/*
  267. X * The system is very weak.  The client uses no encryption for  it
  268. X * credentials and only sends null verifiers.  The server sends backs
  269. X * null verifiers or optionally a verifier that suggests a new short hand
  270. X * for the credentials.
  271. X */
  272. X
  273. X/* The machine name is part of a credential; it may not exceed 255 bytes */
  274. X#define MAX_MACHINE_NAME 255
  275. X
  276. X/* gids compose part of a credential; there may not be more than 10 of them */
  277. X#define NGRPS 8
  278. X
  279. X/*
  280. X * Unix style credentials.
  281. X */
  282. Xstruct authunix_parms {
  283. X    u_long     aup_time;
  284. X    char    *aup_machname;
  285. X    int     aup_uid;
  286. X    int     aup_gid;
  287. X    u_int     aup_len;
  288. X    int    *aup_gids;
  289. X};
  290. X
  291. Xextern bool_t xdr_authunix_parms();
  292. X
  293. X/* 
  294. X * If a response verifier has flavor AUTH_SHORT, 
  295. X * then the body of the response verifier encapsulates the following structure;
  296. X * again it is serialized in the obvious fashion.
  297. X */
  298. Xstruct short_hand_verf {
  299. X    struct opaque_auth new_cred;
  300. X};
  301. SHAR_EOF
  302. if test 2343 -ne "`wc -c < 'rpc/rpclib/auth_unix.h'`"
  303. then
  304.     echo shar: "error transmitting 'rpc/rpclib/auth_unix.h'" '(should have been 2343 characters)'
  305. fi
  306. chmod 444 'rpc/rpclib/auth_unix.h'
  307. fi
  308. echo shar: "extracting 'rpc/rpclib/clnt.h'" '(6991 characters)'
  309. if test -f 'rpc/rpclib/clnt.h'
  310. then
  311.     echo shar: "will not over-write existing file 'rpc/rpclib/clnt.h'"
  312. else
  313. sed 's/^X//' << \SHAR_EOF > 'rpc/rpclib/clnt.h'
  314. X/*
  315. X * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  316. X * unrestricted use provided that this legend is included on all tape
  317. X * media and as a part of the software program in whole or part.  Users
  318. X * may copy or modify Sun RPC without charge, but are not authorized
  319. X * to license or distribute it to anyone else except as part of a product or
  320. X * program developed by the user.
  321. X * 
  322. X * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  323. X * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  324. X * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  325. X * 
  326. X * Sun RPC is provided with no support and without any obligation on the
  327. X * part of Sun Microsystems, Inc. to assist in its use, correction,
  328. X * modification or enhancement.
  329. X * 
  330. X * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  331. X * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  332. X * OR ANY PART THEREOF.
  333. X * 
  334. X * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  335. X * or profits or other special, indirect and consequential damages, even if
  336. X * Sun has been advised of the possibility of such damages.
  337. X * 
  338. X * Sun Microsystems, Inc.
  339. X * 2550 Garcia Avenue
  340. X * Mountain View, California  94043
  341. X */
  342. X/*    @(#)clnt.h 1.1 86/02/03 SMI      */
  343. X
  344. X/*
  345. X * clnt.h - Client side remote procedure call interface.
  346. X *
  347. X * Copyright (C) 1984, Sun Microsystems, Inc.
  348. X */
  349. X
  350. X/*
  351. X * Rpc calls return an enum clnt_stat.  This should be looked at more,
  352. X * since each implementation is required to live with this (implementation
  353. X * independent) list of errors.
  354. X */
  355. Xenum clnt_stat {
  356. X    RPC_SUCCESS=0,            /* call succeeded */
  357. X    /*
  358. X     * local errors
  359. X     */
  360. X    RPC_CANTENCODEARGS=1,        /* can't encode arguments */
  361. X    RPC_CANTDECODERES=2,        /* can't decode results */
  362. X    RPC_CANTSEND=3,            /* failure in sending call */
  363. X    RPC_CANTRECV=4,            /* failure in receiving result */
  364. X    RPC_TIMEDOUT=5,            /* call timed out */
  365. X    /*
  366. X     * remote errors
  367. X     */
  368. X    RPC_VERSMISMATCH=6,        /* rpc versions not compatible */
  369. X    RPC_AUTHERROR=7,        /* authentication error */
  370. X    RPC_PROGUNAVAIL=8,        /* program not available */
  371. X    RPC_PROGVERSMISMATCH=9,        /* program version mismatched */
  372. X    RPC_PROCUNAVAIL=10,        /* procedure unavailable */
  373. X    RPC_CANTDECODEARGS=11,        /* decode arguments error */
  374. X    RPC_SYSTEMERROR=12,        /* generic "other problem" */
  375. X
  376. X    /*
  377. X     * callrpc errors
  378. X     */
  379. X    RPC_UNKNOWNHOST=13,        /* unknown host name */
  380. X
  381. X    /*
  382. X     * _ create errors
  383. X     */
  384. X    RPC_PMAPFAILURE=14,        /* the pmapper failed in its call */
  385. X    RPC_PROGNOTREGISTERED=15,    /* remote program is not registered */
  386. X    /*
  387. X     * unspecified error
  388. X     */
  389. X    RPC_FAILED=16
  390. X};
  391. X
  392. X
  393. X/*
  394. X * Error info.
  395. X */
  396. Xstruct rpc_err {
  397. X    enum clnt_stat re_status;
  398. X    union {
  399. X        int RE_errno;        /* realated system error */
  400. X        enum auth_stat RE_why;    /* why the auth error occurred */
  401. X        struct {
  402. X            u_long low;    /* lowest verion supported */
  403. X            u_long high;    /* highest verion supported */
  404. X        } RE_vers;
  405. X        struct {        /* maybe meaningful if RPC_FAILED */
  406. X            long s1;
  407. X            long s2;
  408. X        } RE_lb;        /* life boot & debugging only */
  409. X    } ru;
  410. X#define    re_errno    ru.RE_errno
  411. X#define    re_why        ru.RE_why
  412. X#define    re_vers        ru.RE_vers
  413. X#define    re_lb        ru.RE_lb
  414. X};
  415. X
  416. X
  417. X/*
  418. X * Client rpc handle.
  419. X * Created by individual implementations, see e.g. rpc_udp.c.
  420. X * Client is responsible for initializing auth, see e.g. auth_none.c.
  421. X */
  422. Xtypedef struct {
  423. X    AUTH    *cl_auth;            /* authenticator */
  424. X    struct clnt_ops {
  425. X        enum clnt_stat    (*cl_call)();    /* call remote procedure */
  426. X        void        (*cl_abort)();    /* abort a call */
  427. X        void        (*cl_geterr)();    /* get specific error code */
  428. X        bool_t        (*cl_freeres)(); /* frees results */
  429. X        void        (*cl_destroy)();/* destroy this structure */
  430. X    } *cl_ops;
  431. X    caddr_t            cl_private;    /* private stuff */
  432. X} CLIENT;
  433. X
  434. X
  435. X/*
  436. X * client side rpc interface ops
  437. X *
  438. X * Parameter types are:
  439. X *
  440. X */
  441. X
  442. X/*
  443. X * enum clnt_stat
  444. X * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
  445. X *     CLIENT *rh;
  446. X *    u_long proc;
  447. X *    xdrproc_t xargs;
  448. X *    caddr_t argsp;
  449. X *    xdrproc_t xres;
  450. X *    caddr_t resp;
  451. X *    struct timeval timeout;
  452. X */
  453. X#define    CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs)    \
  454. X    ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
  455. X#define    clnt_call(rh, proc, xargs, argsp, xres, resp, secs)    \
  456. X    ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
  457. X
  458. X/*
  459. X * void
  460. X * CLNT_ABORT(rh);
  461. X *     CLIENT *rh;
  462. X */
  463. X#define    CLNT_ABORT(rh)    ((*(rh)->cl_ops->cl_abort)(rh))
  464. X#define    clnt_abort(rh)    ((*(rh)->cl_ops->cl_abort)(rh))
  465. X
  466. X/*
  467. X * struct rpc_err
  468. X * CLNT_GETERR(rh);
  469. X *     CLIENT *rh;
  470. X */
  471. X#define    CLNT_GETERR(rh,errp)    ((*(rh)->cl_ops->cl_geterr)(rh, errp))
  472. X#define    clnt_geterr(rh,errp)    ((*(rh)->cl_ops->cl_geterr)(rh, errp))
  473. X
  474. X
  475. X/*
  476. X * bool_t
  477. X * CLNT_FREERES(rh, xres, resp);
  478. X *     CLIENT *rh;
  479. X *    xdrproc_t xres;
  480. X *    caddr_t resp;
  481. X */
  482. X#define    CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
  483. X#define    clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
  484. X
  485. X/*
  486. X * void
  487. X * CLNT_DESTROY(rh);
  488. X *     CLIENT *rh;
  489. X */
  490. X#define    CLNT_DESTROY(rh)    ((*(rh)->cl_ops->cl_destroy)(rh))
  491. X#define    clnt_destroy(rh)    ((*(rh)->cl_ops->cl_destroy)(rh))
  492. X
  493. X
  494. X/*
  495. X * RPCTEST is a test program which is accessable on every rpc
  496. X * transport/port.  It is used for testing, performance evaluation,
  497. X * and network administration.
  498. X */
  499. X
  500. X#define RPCTEST_PROGRAM        ((u_long)1)
  501. X#define RPCTEST_VERSION        ((u_long)1)
  502. X#define RPCTEST_NULL_PROC    ((u_long)2)
  503. X#define RPCTEST_NULL_BATCH_PROC    ((u_long)3)
  504. X
  505. X/*
  506. X * By convention, procedure 0 takes null arguments and returns them
  507. X */
  508. X
  509. X#define NULLPROC ((u_long)0)
  510. X
  511. X/*
  512. X * Below are the client handle creation routines for the various
  513. X * implementations of client side rpc.  They can return NULL if a 
  514. X * creation failure occurs.
  515. X */
  516. X
  517. X/*
  518. X * Memory based rpc (for speed check and testing)
  519. X * CLIENT *
  520. X * clntraw_create(prog, vers)
  521. X *    u_long prog;
  522. X *    u_long vers;
  523. X */
  524. Xextern CLIENT *clntraw_create();
  525. X
  526. X/*
  527. X * TCP based rpc
  528. X * CLIENT *
  529. X * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
  530. X *    struct sockaddr_in *raddr;
  531. X *    u_long prog;
  532. X *    u_long version;
  533. X *    register int *sockp;
  534. X *    u_int sendsz;
  535. X *    u_int recvsz;
  536. X */
  537. Xextern CLIENT *clnttcp_create();
  538. X
  539. X/*
  540. X * UDP based rpc.
  541. X * CLIENT *
  542. X * clntudp_create(raddr, program, version, wait, sockp)
  543. X *    struct sockaddr_in *raddr;
  544. X *    u_long program;
  545. X *    u_long version;
  546. X *    struct timeval wait;
  547. X *    int *sockp;
  548. X *
  549. X * Same as above, but you specify max packet sizes.
  550. X * CLIENT *
  551. X * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
  552. X *    struct sockaddr_in *raddr;
  553. X *    u_long program;
  554. X *    u_long version;
  555. X *    struct timeval wait;
  556. X *    int *sockp;
  557. X *    u_int sendsz;
  558. X *    u_int recvsz;
  559. X */
  560. Xextern CLIENT *clntudp_create();
  561. Xextern CLIENT *clntudp_bufcreate();
  562. X
  563. X/* 
  564. X * If a creation fails, the following allows the user to figure out why.
  565. X */
  566. Xstruct rpc_createerr {
  567. X    enum clnt_stat cf_stat;
  568. X    struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */
  569. X};
  570. X
  571. Xextern struct rpc_createerr rpc_createerr;
  572. X
  573. X
  574. X#define UDPMSGSIZE    8800    /* rpc imposed limit on udp msg size */
  575. X#define RPCSMALLMSGSIZE    400    /* a more reasonable packet size */
  576. SHAR_EOF
  577. if test 6991 -ne "`wc -c < 'rpc/rpclib/clnt.h'`"
  578. then
  579.     echo shar: "error transmitting 'rpc/rpclib/clnt.h'" '(should have been 6991 characters)'
  580. fi
  581. chmod 444 'rpc/rpclib/clnt.h'
  582. fi
  583. echo shar: "extracting 'rpc/rpclib/pmap_clnt.h'" '(2481 characters)'
  584. if test -f 'rpc/rpclib/pmap_clnt.h'
  585. then
  586.     echo shar: "will not over-write existing file 'rpc/rpclib/pmap_clnt.h'"
  587. else
  588. sed 's/^X//' << \SHAR_EOF > 'rpc/rpclib/pmap_clnt.h'
  589. X/*
  590. X * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  591. X * unrestricted use provided that this legend is included on all tape
  592. X * media and as a part of the software program in whole or part.  Users
  593. X * may copy or modify Sun RPC without charge, but are not authorized
  594. X * to license or distribute it to anyone else except as part of a product or
  595. X * program developed by the user.
  596. X * 
  597. X * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  598. X * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  599. X * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  600. X * 
  601. X * Sun RPC is provided with no support and without any obligation on the
  602. X * part of Sun Microsystems, Inc. to assist in its use, correction,
  603. X * modification or enhancement.
  604. X * 
  605. X * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  606. X * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  607. X * OR ANY PART THEREOF.
  608. X * 
  609. X * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  610. X * or profits or other special, indirect and consequential damages, even if
  611. X * Sun has been advised of the possibility of such damages.
  612. X * 
  613. X * Sun Microsystems, Inc.
  614. X * 2550 Garcia Avenue
  615. X * Mountain View, California  94043
  616. X */
  617. X/*    @(#)pmap_clnt.h 1.1 86/02/03 SMI    */
  618. X
  619. X/*
  620. X * portmap_clnt.h
  621. X * Supplies C routines to get to portmap services.
  622. X *
  623. X * Copyright (C) 1984, Sun Microsystems, Inc.
  624. X */
  625. X
  626. X/*
  627. X * Usage:
  628. X *    success = pmap_set(program, version, protocol, port);
  629. X *    success = pmap_unset(program, version);
  630. X *    port = pmap_getport(address, program, version, protocol);
  631. X *    head = pmap_getmaps(address);
  632. X *    clnt_stat = pmap_rmtcall(address, program, version, procedure,
  633. X *        xdrargs, argsp, xdrres, resp, tout, port_ptr)
  634. X *        (works for udp only.) 
  635. X *     clnt_stat = clnt_broadcast(program, version, procedure,
  636. X *        xdrargs, argsp,    xdrres, resp, eachresult)
  637. X *        (like pmap_rmtcall, except the call is broadcasted to all
  638. X *        locally connected nets.  For each valid response received,
  639. X *        the procedure eachresult is called.  Its form is:
  640. X *    done = eachresult(resp, raddr)
  641. X *        bool_t done;
  642. X *        caddr_t resp;
  643. X *        struct sockaddr_in raddr;
  644. X *        where resp points to the results of the call and raddr is the
  645. X *        address if the responder to the broadcast.
  646. X */
  647. X
  648. Xextern bool_t        pmap_set();
  649. Xextern bool_t        pmap_unset();
  650. Xextern u_short        pmap_getport();
  651. Xextern struct pmaplist    *pmap_getmaps();
  652. Xenum clnt_stat        pmap_rmtcall();
  653. Xenum clnt_stat        clnt_broadcast();
  654. SHAR_EOF
  655. if test 2481 -ne "`wc -c < 'rpc/rpclib/pmap_clnt.h'`"
  656. then
  657.     echo shar: "error transmitting 'rpc/rpclib/pmap_clnt.h'" '(should have been 2481 characters)'
  658. fi
  659. chmod 444 'rpc/rpclib/pmap_clnt.h'
  660. fi
  661. echo shar: "extracting 'rpc/rpclib/pmap_prot.h'" '(3302 characters)'
  662. if test -f 'rpc/rpclib/pmap_prot.h'
  663. then
  664.     echo shar: "will not over-write existing file 'rpc/rpclib/pmap_prot.h'"
  665. else
  666. sed 's/^X//' << \SHAR_EOF > 'rpc/rpclib/pmap_prot.h'
  667. X/*
  668. X * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  669. X * unrestricted use provided that this legend is included on all tape
  670. X * media and as a part of the software program in whole or part.  Users
  671. X * may copy or modify Sun RPC without charge, but are not authorized
  672. X * to license or distribute it to anyone else except as part of a product or
  673. X * program developed by the user.
  674. X * 
  675. X * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  676. X * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  677. X * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  678. X * 
  679. X * Sun RPC is provided with no support and without any obligation on the
  680. X * part of Sun Microsystems, Inc. to assist in its use, correction,
  681. X * modification or enhancement.
  682. X * 
  683. X * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  684. X * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  685. X * OR ANY PART THEREOF.
  686. X * 
  687. X * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  688. X * or profits or other special, indirect and consequential damages, even if
  689. X * Sun has been advised of the possibility of such damages.
  690. X * 
  691. X * Sun Microsystems, Inc.
  692. X * 2550 Garcia Avenue
  693. X * Mountain View, California  94043
  694. X */
  695. X/*    @(#)pmap_prot.h 1.1 86/02/03 SMI    */
  696. X
  697. X/*
  698. X * pmap_prot.h
  699. X * Protocol for the local binder service, or pmap.
  700. X *
  701. X * Copyright (C) 1984, Sun Microsystems, Inc.
  702. X *
  703. X * The following procedures are supported by the protocol:
  704. X *
  705. X * PMAPPROC_NULL() returns ()
  706. X *     takes nothing, returns nothing
  707. X *
  708. X * PMAPPROC_SET(struct pmap) returns (bool_t)
  709. X *     TRUE is success, FALSE is failure.  Registers the tuple
  710. X *    [prog, vers, prot, port].
  711. X *
  712. X * PMAPPROC_UNSET(struct pmap) returns (bool_t)
  713. X *    TRUE is success, FALSE is failure.  Un-registers pair
  714. X *    [prog, vers].  prot and port are ignored.
  715. X *
  716. X * PMAPPROC_GETPORT(struct pmap) returns (long unsigned).
  717. X *    0 is failure.  Otherwise returns the port number where the pair
  718. X *    [prog, vers] is registered.  It may lie!
  719. X *
  720. X * PMAPPROC_DUMP() RETURNS (struct pmaplist *)
  721. X *
  722. X * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>)
  723. X *     RETURNS (port, string<>);
  724. X * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs);
  725. X *     Calls the procedure on the local machine.  If it is not registered,
  726. X *    this procedure is quite; ie it does not return error information!!!
  727. X *    This procedure only is supported on rpc/udp and calls via
  728. X *    rpc/udp.  This routine only passes null authentication parameters.
  729. X *    This file has no interface to xdr routines for PMAPPROC_CALLIT.
  730. X *
  731. X * The service supports remote procedure calls on udp/ip or tcp/ip socket 111.
  732. X */
  733. X
  734. X#define PMAPPORT        ((u_short)111)
  735. X#define PMAPPROG        ((u_long)100000)
  736. X#define PMAPVERS        ((u_long)2)
  737. X#define PMAPVERS_PROTO        ((u_long)2)
  738. X#define PMAPVERS_ORIG        ((u_long)1)
  739. X#define PMAPPROC_NULL        ((u_long)0)
  740. X#define PMAPPROC_SET        ((u_long)1)
  741. X#define PMAPPROC_UNSET        ((u_long)2)
  742. X#define PMAPPROC_GETPORT    ((u_long)3)
  743. X#define PMAPPROC_DUMP        ((u_long)4)
  744. X#define PMAPPROC_CALLIT        ((u_long)5)
  745. X
  746. Xstruct pmap {
  747. X    long unsigned pm_prog;
  748. X    long unsigned pm_vers;
  749. X    long unsigned pm_prot;
  750. X    long unsigned pm_port;
  751. X};
  752. X
  753. Xextern bool_t xdr_pmap();
  754. X
  755. Xstruct pmaplist {
  756. X    struct pmap    pml_map;
  757. X    struct pmaplist *pml_next;
  758. X};
  759. X
  760. Xextern bool_t xdr_pmaplist();
  761. SHAR_EOF
  762. if test 3302 -ne "`wc -c < 'rpc/rpclib/pmap_prot.h'`"
  763. then
  764.     echo shar: "error transmitting 'rpc/rpclib/pmap_prot.h'" '(should have been 3302 characters)'
  765. fi
  766. chmod 444 'rpc/rpclib/pmap_prot.h'
  767. fi
  768. echo shar: "extracting 'rpc/rpclib/rpc.h'" '(2153 characters)'
  769. if test -f 'rpc/rpclib/rpc.h'
  770. then
  771.     echo shar: "will not over-write existing file 'rpc/rpclib/rpc.h'"
  772. else
  773. sed 's/^X//' << \SHAR_EOF > 'rpc/rpclib/rpc.h'
  774. X/*
  775. X * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  776. X * unrestricted use provided that this legend is included on all tape
  777. X * media and as a part of the software program in whole or part.  Users
  778. X * may copy or modify Sun RPC without charge, but are not authorized
  779. X * to license or distribute it to anyone else except as part of a product or
  780. X * program developed by the user.
  781. X * 
  782. X * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  783. X * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  784. X * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  785. X * 
  786. X * Sun RPC is provided with no support and without any obligation on the
  787. X * part of Sun Microsystems, Inc. to assist in its use, correction,
  788. X * modification or enhancement.
  789. X * 
  790. X * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  791. X * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  792. X * OR ANY PART THEREOF.
  793. X * 
  794. X * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  795. X * or profits or other special, indirect and consequential damages, even if
  796. X * Sun has been advised of the possibility of such damages.
  797. X * 
  798. X * Sun Microsystems, Inc.
  799. X * 2550 Garcia Avenue
  800. X * Mountain View, California  94043
  801. X */
  802. X/*    @(#)rpc.h 1.1 86/02/03 SMI    */
  803. X
  804. X/*
  805. X * rpc.h, Just includes the billions of rpc header files necessary to 
  806. X * do remote procedure calling.
  807. X *
  808. X * Copyright (C) 1984, Sun Microsystems, Inc.
  809. X */
  810. X
  811. X#include <rpc/types.h>        /* some typedefs */
  812. X#include <netinet/in.h>
  813. X
  814. X/* external data representation interfaces */
  815. X#include <rpc/xdr.h>        /* generic (de)serializer */
  816. X
  817. X/* Client side only authentication */
  818. X#include <rpc/auth.h>        /* generic authenticator (client side) */
  819. X
  820. X/* Client side (mostly) remote procedure call */
  821. X#include <rpc/clnt.h>        /* generic rpc stuff */
  822. X
  823. X/* semi-private protocol headers */
  824. X#include <rpc/rpc_msg.h>    /* protocol for rpc messages */
  825. X#include <rpc/auth_unix.h>    /* protocol for unix style cred */
  826. X
  827. X/* Server side only remote procedure callee */
  828. X#include <rpc/svc.h>        /* service manager and multiplexer */
  829. X#include <rpc/svc_auth.h>    /* service side authenticator */
  830. SHAR_EOF
  831. if test 2153 -ne "`wc -c < 'rpc/rpclib/rpc.h'`"
  832. then
  833.     echo shar: "error transmitting 'rpc/rpclib/rpc.h'" '(should have been 2153 characters)'
  834. fi
  835. chmod 444 'rpc/rpclib/rpc.h'
  836. fi
  837. echo shar: "extracting 'rpc/rpclib/rpc_msg.h'" '(4134 characters)'
  838. if test -f 'rpc/rpclib/rpc_msg.h'
  839. then
  840.     echo shar: "will not over-write existing file 'rpc/rpclib/rpc_msg.h'"
  841. else
  842. sed 's/^X//' << \SHAR_EOF > 'rpc/rpclib/rpc_msg.h'
  843. X/*
  844. X * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  845. X * unrestricted use provided that this legend is included on all tape
  846. X * media and as a part of the software program in whole or part.  Users
  847. X * may copy or modify Sun RPC without charge, but are not authorized
  848. X * to license or distribute it to anyone else except as part of a product or
  849. X * program developed by the user.
  850. X * 
  851. X * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  852. X * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  853. X * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  854. X * 
  855. X * Sun RPC is provided with no support and without any obligation on the
  856. X * part of Sun Microsystems, Inc. to assist in its use, correction,
  857. X * modification or enhancement.
  858. X * 
  859. X * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  860. X * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  861. X * OR ANY PART THEREOF.
  862. X * 
  863. X * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  864. X * or profits or other special, indirect and consequential damages, even if
  865. X * Sun has been advised of the possibility of such damages.
  866. X * 
  867. X * Sun Microsystems, Inc.
  868. X * 2550 Garcia Avenue
  869. X * Mountain View, California  94043
  870. X */
  871. X/*      @(#)rpc_msg.h 1.1 86/02/03 SMI      */
  872. X
  873. X/*
  874. X * rpc_msg.h
  875. X * rpc message definition
  876. X *
  877. X * Copyright (C) 1984, Sun Microsystems, Inc.
  878. X */
  879. X
  880. X#define RPC_MSG_VERSION        ((u_long) 2)
  881. X#define RPC_SERVICE_PORT    ((u_short) 2048)
  882. X
  883. X/*
  884. X * Bottom up definition of an rpc message.
  885. X * NOTE: call and reply use the same overall stuct but
  886. X * different parts of unions within it.
  887. X */
  888. X
  889. Xenum msg_type {
  890. X    CALL=0,
  891. X    REPLY=1
  892. X};
  893. X
  894. Xenum reply_stat {
  895. X    MSG_ACCEPTED=0,
  896. X    MSG_DENIED=1
  897. X};
  898. X
  899. Xenum accept_stat {
  900. X    SUCCESS=0,
  901. X    PROG_UNAVAIL=1,
  902. X    PROG_MISMATCH=2,
  903. X    PROC_UNAVAIL=3,
  904. X    GARBAGE_ARGS=4,
  905. X    SYSTEM_ERR=5
  906. X};
  907. X
  908. Xenum reject_stat {
  909. X    RPC_MISMATCH=0,
  910. X    AUTH_ERROR=1
  911. X};
  912. X
  913. X/*
  914. X * Reply part of an rpc exchange
  915. X */
  916. X
  917. X/*
  918. X * Reply to an rpc request that was accepted by the server.
  919. X * Note: there could be an error even though the request was
  920. X * accepted.
  921. X */
  922. Xstruct accepted_reply {
  923. X    struct opaque_auth    ar_verf;
  924. X    enum accept_stat    ar_stat;
  925. X    union {
  926. X        struct {
  927. X            u_long    low;
  928. X            u_long    high;
  929. X        } AR_versions;
  930. X        struct {
  931. X            caddr_t    where;
  932. X            xdrproc_t proc;
  933. X        } AR_results;
  934. X        /* and many other null cases */
  935. X    } ru;
  936. X#define    ar_results    ru.AR_results
  937. X#define    ar_vers        ru.AR_versions
  938. X};
  939. X
  940. X/*
  941. X * Reply to an rpc request that was rejected by the server.
  942. X */
  943. Xstruct rejected_reply {
  944. X    enum reject_stat rj_stat;
  945. X    union {
  946. X        struct {
  947. X            u_long low;
  948. X            u_long high;
  949. X        } RJ_versions;
  950. X        enum auth_stat RJ_why;  /* why authentication did not work */
  951. X    } ru;
  952. X#define    rj_vers    ru.RJ_versions
  953. X#define    rj_why    ru.RJ_why
  954. X};
  955. X
  956. X/*
  957. X * Body of a reply to an rpc request.
  958. X */
  959. Xstruct reply_body {
  960. X    enum reply_stat rp_stat;
  961. X    union {
  962. X        struct accepted_reply RP_ar;
  963. X        struct rejected_reply RP_dr;
  964. X    } ru;
  965. X#define    rp_acpt    ru.RP_ar
  966. X#define    rp_rjct    ru.RP_dr
  967. X};
  968. X
  969. X/*
  970. X * Body of an rpc request call.
  971. X */
  972. Xstruct call_body {
  973. X    u_long cb_rpcvers;    /* must be equal to two */
  974. X    u_long cb_prog;
  975. X    u_long cb_vers;
  976. X    u_long cb_proc;
  977. X    struct opaque_auth cb_cred;
  978. X    struct opaque_auth cb_verf; /* protocol specific - provided by client */
  979. X};
  980. X
  981. X/*
  982. X * The rpc message
  983. X */
  984. Xstruct rpc_msg {
  985. X    u_long            rm_xid;
  986. X    enum msg_type        rm_direction;
  987. X    union {
  988. X        struct call_body RM_cmb;
  989. X        struct reply_body RM_rmb;
  990. X    } ru;
  991. X#define    rm_call        ru.RM_cmb
  992. X#define    rm_reply    ru.RM_rmb
  993. X};
  994. X#define    acpted_rply    ru.RM_rmb.ru.RP_ar
  995. X#define    rjcted_rply    ru.RM_rmb.ru.RP_dr
  996. X
  997. X
  998. X/*
  999. X * XDR routine to handle a rpc message.
  1000. X * xdr_callmsg(xdrs, cmsg)
  1001. X *     XDR *xdrs;
  1002. X *     struct rpc_msg *cmsg;
  1003. X */
  1004. Xextern bool_t    xdr_callmsg();
  1005. X
  1006. X/*
  1007. X * XDR routine to pre-serialize the static part of a rpc message.
  1008. X * xdr_callhdr(xdrs, cmsg)
  1009. X *     XDR *xdrs;
  1010. X *     struct rpc_msg *cmsg;
  1011. X */
  1012. Xextern bool_t    xdr_callhdr();
  1013. X
  1014. X/*
  1015. X * XDR routine to handle a rpc reply.
  1016. X * xdr_replymsg(xdrs, rmsg)
  1017. X *     XDR *xdrs;
  1018. X *     struct rpc_msg *rmsg;
  1019. X */
  1020. Xextern bool_t    xdr_replymsg();
  1021. X
  1022. X/*
  1023. X * Fills in the error part of a reply message.
  1024. X * _seterr_reply(msg, error)
  1025. X *     struct rpc_msg *msg;
  1026. X *     struct rpc_err *error;
  1027. X */
  1028. Xextern void    _seterr_reply();
  1029. SHAR_EOF
  1030. if test 4134 -ne "`wc -c < 'rpc/rpclib/rpc_msg.h'`"
  1031. then
  1032.     echo shar: "error transmitting 'rpc/rpclib/rpc_msg.h'" '(should have been 4134 characters)'
  1033. fi
  1034. chmod 444 'rpc/rpclib/rpc_msg.h'
  1035. fi
  1036. echo shar: "extracting 'rpc/rpclib/svc.h'" '(8333 characters)'
  1037. if test -f 'rpc/rpclib/svc.h'
  1038. then
  1039.     echo shar: "will not over-write existing file 'rpc/rpclib/svc.h'"
  1040. else
  1041. sed 's/^X//' << \SHAR_EOF > 'rpc/rpclib/svc.h'
  1042. X/*
  1043. X * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  1044. X * unrestricted use provided that this legend is included on all tape
  1045. X * media and as a part of the software program in whole or part.  Users
  1046. X * may copy or modify Sun RPC without charge, but are not authorized
  1047. X * to license or distribute it to anyone else except as part of a product or
  1048. X * program developed by the user.
  1049. X * 
  1050. X * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  1051. X * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  1052. X * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  1053. X * 
  1054. X * Sun RPC is provided with no support and without any obligation on the
  1055. X * part of Sun Microsystems, Inc. to assist in its use, correction,
  1056. X * modification or enhancement.
  1057. X * 
  1058. X * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  1059. X * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  1060. X * OR ANY PART THEREOF.
  1061. X * 
  1062. X * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  1063. X * or profits or other special, indirect and consequential damages, even if
  1064. X * Sun has been advised of the possibility of such damages.
  1065. X * 
  1066. X * Sun Microsystems, Inc.
  1067. X * 2550 Garcia Avenue
  1068. X * Mountain View, California  94043
  1069. X */
  1070. X/*      @(#)svc.h 1.1 86/02/03 SMI      *
  1071. X
  1072. X/*
  1073. X * svc.h, Server-side remote procedure call interface.
  1074. X *
  1075. X * Copyright (C) 1984, Sun Microsystems, Inc.
  1076. X */
  1077. X
  1078. X/*
  1079. X * This interface must manage two items concerning remote procedure calling:
  1080. X *
  1081. X * 1) An arbitrary number of transport connections upon which rpc requests
  1082. X * are received.  The two most notable transports are TCP and UDP;  they are
  1083. X * created and registered by routines in svc_tcp.c and svc_udp.c, respectively;
  1084. X * they in turn call xprt_register and xprt_unregister.
  1085. X *
  1086. X * 2) An arbitrary number of locally registered services.  Services are
  1087. X * described by the following four data: program number, version number,
  1088. X * "service dispatch" function, a transport handle, and a boolean that
  1089. X * indicates whether or not the exported program should be registered with a
  1090. X * local binder service;  if true the program's number and version and the
  1091. X * port number from the transport handle are registered with the binder.
  1092. X * These data are registered with the rpc svc system via svc_register.
  1093. X *
  1094. X * A service's dispatch function is called whenever an rpc request comes in
  1095. X * on a transport.  The request's program and version numbers must match
  1096. X * those of the registered service.  The dispatch function is passed two
  1097. X * parameters, struct svc_req * and SVCXPRT *, defined below.
  1098. X */
  1099. X
  1100. Xenum xprt_stat {
  1101. X    XPRT_DIED,
  1102. X    XPRT_MOREREQS,
  1103. X    XPRT_IDLE
  1104. X};
  1105. X
  1106. X/*
  1107. X * Server side transport handle
  1108. X */
  1109. Xtypedef struct {
  1110. X    int        xp_sock;
  1111. X    u_short        xp_port;     /* associated port number */
  1112. X    struct xp_ops {
  1113. X        bool_t    (*xp_recv)();     /* receive incomming requests */
  1114. X        enum xprt_stat (*xp_stat)(); /* get transport status */
  1115. X        bool_t    (*xp_getargs)(); /* get arguments */
  1116. X        bool_t    (*xp_reply)();     /* send reply */
  1117. X        bool_t    (*xp_freeargs)();/* free mem allocated for args */
  1118. X        void    (*xp_destroy)(); /* destroy this struct */
  1119. X    } *xp_ops;
  1120. X    int        xp_addrlen;     /* length of remote address */
  1121. X    struct sockaddr_in xp_raddr;     /* remote address */
  1122. X    struct opaque_auth xp_verf;     /* raw response verifier */
  1123. X    caddr_t        xp_p1;         /* private */
  1124. X    caddr_t        xp_p2;         /* private */
  1125. X} SVCXPRT;
  1126. X
  1127. X/*
  1128. X *  Approved way of getting address of caller
  1129. X */
  1130. X#define svc_getcaller(x) (&(x)->xp_raddr)
  1131. X
  1132. X/*
  1133. X * Operations defined on an SVCXPRT handle
  1134. X *
  1135. X * SVCXPRT        *xprt;
  1136. X * struct rpc_msg    *msg;
  1137. X * xdrproc_t         xargs;
  1138. X * caddr_t         argsp;
  1139. X */
  1140. X#define SVC_RECV(xprt, msg)                \
  1141. X    (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
  1142. X#define svc_recv(xprt, msg)                \
  1143. X    (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
  1144. X
  1145. X#define SVC_STAT(xprt)                    \
  1146. X    (*(xprt)->xp_ops->xp_stat)(xprt)
  1147. X#define svc_stat(xprt)                    \
  1148. X    (*(xprt)->xp_ops->xp_stat)(xprt)
  1149. X
  1150. X#define SVC_GETARGS(xprt, xargs, argsp)            \
  1151. X    (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
  1152. X#define svc_getargs(xprt, xargs, argsp)            \
  1153. X    (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
  1154. X
  1155. X#define SVC_REPLY(xprt, msg)                \
  1156. X    (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
  1157. X#define svc_reply(xprt, msg)                \
  1158. X    (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
  1159. X
  1160. X#define SVC_FREEARGS(xprt, xargs, argsp)        \
  1161. X    (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
  1162. X#define svc_freeargs(xprt, xargs, argsp)        \
  1163. X    (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
  1164. X
  1165. X#define SVC_DESTROY(xprt)                \
  1166. X    (*(xprt)->xp_ops->xp_destroy)(xprt)
  1167. X#define svc_destroy(xprt)                \
  1168. X    (*(xprt)->xp_ops->xp_destroy)(xprt)
  1169. X
  1170. X
  1171. X/*
  1172. X * Service request
  1173. X */
  1174. Xstruct svc_req {
  1175. X    u_long        rq_prog;    /* service program number */
  1176. X    u_long        rq_vers;    /* service protocol version */
  1177. X    u_long        rq_proc;    /* the desired procedure */
  1178. X    struct opaque_auth rq_cred;    /* raw creds from the wire */
  1179. X    caddr_t        rq_clntcred;    /* read only cooked cred */
  1180. X    SVCXPRT    *rq_xprt;        /* associated transport */
  1181. X};
  1182. X
  1183. X
  1184. X/*
  1185. X * Service registration
  1186. X *
  1187. X * svc_register(xprt, prog, vers, dispatch, protocol)
  1188. X *    SVCXPRT *xprt;
  1189. X *    u_long prog;
  1190. X *    u_long vers;
  1191. X *    void (*dispatch)();
  1192. X *    int protocol;  /* like TCP or UDP, zero means do not register 
  1193. X */
  1194. Xextern bool_t    svc_register();
  1195. X
  1196. X/*
  1197. X * Service un-registration
  1198. X *
  1199. X * svc_unregister(prog, vers)
  1200. X *    u_long prog;
  1201. X *    u_long vers;
  1202. X */
  1203. Xextern void    svc_unregister();
  1204. X
  1205. X/*
  1206. X * Transport registration.
  1207. X *
  1208. X * xprt_register(xprt)
  1209. X *    SVCXPRT *xprt;
  1210. X */
  1211. Xextern void    xprt_register();
  1212. X
  1213. X/*
  1214. X * Transport un-register
  1215. X *
  1216. X * xprt_unregister(xprt)
  1217. X *    SVCXPRT *xprt;
  1218. X */
  1219. Xextern void    xprt_unregister();
  1220. X
  1221. X
  1222. X/*
  1223. X * When the service routine is called, it must first check to see if it
  1224. X * knows about the procedure;  if not, it should call svcerr_noproc
  1225. X * and return.  If so, it should deserialize its arguments via 
  1226. X * SVC_GETARGS (defined above).  If the deserialization does not work,
  1227. X * svcerr_decode should be called followed by a return.  Successful
  1228. X * decoding of the arguments should be followed the execution of the
  1229. X * procedure's code and a call to svc_sendreply.
  1230. X *
  1231. X * Also, if the service refuses to execute the procedure due to too-
  1232. X * weak authentication parameters, svcerr_weakauth should be called.
  1233. X * Note: do not confuse access-control failure with weak authentication!
  1234. X *
  1235. X * NB: In pure implementations of rpc, the caller always waits for a reply
  1236. X * msg.  This message is sent when svc_sendreply is called.  
  1237. X * Therefore pure service implementations should always call
  1238. X * svc_sendreply even if the function logically returns void;  use
  1239. X * xdr.h - xdr_void for the xdr routine.  HOWEVER, tcp based rpc allows
  1240. X * for the abuse of pure rpc via batched calling or pipelining.  In the
  1241. X * case of a batched call, svc_sendreply should NOT be called since
  1242. X * this would send a return message, which is what batching tries to avoid.
  1243. X * It is the service/protocol writer's responsibility to know which calls are
  1244. X * batched and which are not.  Warning: responding to batch calls may
  1245. X * deadlock the caller and server processes!
  1246. X */
  1247. X
  1248. Xextern bool_t  svc_sendreply();
  1249. Xextern void    svcerr_decode();
  1250. Xextern void    svcerr_weakauth();
  1251. Xextern void    svcerr_noproc();
  1252. X
  1253. X/*
  1254. X * Lowest level dispatching -OR- who owns this process anyway.
  1255. X * Somebody has to wait for incoming requests and then call the correct
  1256. X * service routine.  The routine svc_run does infinite waiting; i.e.,
  1257. X * svc_run never returns.
  1258. X * Since another (co-existant) package may wish to selectively wait for
  1259. X * incoming calls or other events outside of the rpc architecture, the
  1260. X * routine svc_getreq is provided.  It must be passed readfds, the
  1261. X * "in-place" results of a select system call (see select, section 2).
  1262. X */
  1263. X
  1264. X/* dynamic; must be inspected before each call to select */
  1265. Xextern int svc_fds;
  1266. X
  1267. X/*
  1268. X * a small program implemented by the svc_rpc implementation itself;
  1269. X * also see clnt.h for protocol numbers.
  1270. X */
  1271. Xextern void rpctest_service();
  1272. X
  1273. Xextern void    svc_getreq();
  1274. Xextern void    svc_run();      /* never returns */
  1275. X
  1276. X/*
  1277. X * Socket to use on svcxxx_create call to get default socket
  1278. X */
  1279. X#define    RPC_ANYSOCK    -1
  1280. X
  1281. X/*
  1282. X * These are the existing service side transport implementations
  1283. X */
  1284. X
  1285. X/*
  1286. X * Memory based rpc for testing and timing.
  1287. X */
  1288. Xextern SVCXPRT *svcraw_create();
  1289. X
  1290. X/*
  1291. X * Udp based rpc.
  1292. X */
  1293. Xextern SVCXPRT *svcudp_create();
  1294. Xextern SVCXPRT *svcudp_bufcreate();
  1295. X
  1296. X/*
  1297. X * Tcp based rpc.
  1298. X */
  1299. Xextern SVCXPRT *svctcp_create();
  1300. X
  1301. SHAR_EOF
  1302. if test 8333 -ne "`wc -c < 'rpc/rpclib/svc.h'`"
  1303. then
  1304.     echo shar: "error transmitting 'rpc/rpclib/svc.h'" '(should have been 8333 characters)'
  1305. fi
  1306. chmod 444 'rpc/rpclib/svc.h'
  1307. fi
  1308. echo shar: "extracting 'rpc/rpclib/svc_auth.h'" '(1503 characters)'
  1309. if test -f 'rpc/rpclib/svc_auth.h'
  1310. then
  1311.     echo shar: "will not over-write existing file 'rpc/rpclib/svc_auth.h'"
  1312. else
  1313. sed 's/^X//' << \SHAR_EOF > 'rpc/rpclib/svc_auth.h'
  1314. X/*
  1315. X * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  1316. X * unrestricted use provided that this legend is included on all tape
  1317. X * media and as a part of the software program in whole or part.  Users
  1318. X * may copy or modify Sun RPC without charge, but are not authorized
  1319. X * to license or distribute it to anyone else except as part of a product or
  1320. X * program developed by the user.
  1321. X * 
  1322. X * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  1323. X * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  1324. X * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  1325. X * 
  1326. X * Sun RPC is provided with no support and without any obligation on the
  1327. X * part of Sun Microsystems, Inc. to assist in its use, correction,
  1328. X * modification or enhancement.
  1329. X * 
  1330. X * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  1331. X * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  1332. X * OR ANY PART THEREOF.
  1333. X * 
  1334. X * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  1335. X * or profits or other special, indirect and consequential damages, even if
  1336. X * Sun has been advised of the possibility of such damages.
  1337. X * 
  1338. X * Sun Microsystems, Inc.
  1339. X * 2550 Garcia Avenue
  1340. X * Mountain View, California  94043
  1341. X */
  1342. X/*      @(#)svc_auth.h 1.1 86/02/03 SMI      */
  1343. X
  1344. X/*
  1345. X * svc_auth.h, Service side of rpc authentication.
  1346. X * 
  1347. X * Copyright (C) 1984, Sun Microsystems, Inc.
  1348. X */
  1349. X
  1350. X
  1351. X/*
  1352. X * Server side authenticator
  1353. X */
  1354. Xextern enum auth_stat _authenticate();
  1355. SHAR_EOF
  1356. if test 1503 -ne "`wc -c < 'rpc/rpclib/svc_auth.h'`"
  1357. then
  1358.     echo shar: "error transmitting 'rpc/rpclib/svc_auth.h'" '(should have been 1503 characters)'
  1359. fi
  1360. chmod 444 'rpc/rpclib/svc_auth.h'
  1361. fi
  1362. echo shar: "extracting 'rpc/rpclib/types.h'" '(1590 characters)'
  1363. if test -f 'rpc/rpclib/types.h'
  1364. then
  1365.     echo shar: "will not over-write existing file 'rpc/rpclib/types.h'"
  1366. else
  1367. sed 's/^X//' << \SHAR_EOF > 'rpc/rpclib/types.h'
  1368. X/*
  1369. X * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  1370. X * unrestricted use provided that this legend is included on all tape
  1371. X * media and as a part of the software program in whole or part.  Users
  1372. X * may copy or modify Sun RPC without charge, but are not authorized
  1373. X * to license or distribute it to anyone else except as part of a product or
  1374. X * program developed by the user.
  1375. X * 
  1376. X * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  1377. X * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  1378. X * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  1379. X * 
  1380. X * Sun RPC is provided with no support and without any obligation on the
  1381. X * part of Sun Microsystems, Inc. to assist in its use, correction,
  1382. X * modification or enhancement.
  1383. X * 
  1384. X * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  1385. X * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  1386. X * OR ANY PART THEREOF.
  1387. X * 
  1388. X * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  1389. X * or profits or other special, indirect and consequential damages, even if
  1390. X * Sun has been advised of the possibility of such damages.
  1391. X * 
  1392. X * Sun Microsystems, Inc.
  1393. X * 2550 Garcia Avenue
  1394. X * Mountain View, California  94043
  1395. X */
  1396. X/*      @(#)types.h 1.1 86/02/03 SMI      */
  1397. X
  1398. X/*
  1399. X * Rpc additions to <sys/types.h>
  1400. X */
  1401. X
  1402. X#define    bool_t    int
  1403. X#define    enum_t    int
  1404. X#define    FALSE    (0)
  1405. X#define    TRUE    (1)
  1406. X#define __dontcare__    -1
  1407. X
  1408. X#define mem_alloc(bsize)    malloc(bsize)
  1409. X#define mem_free(ptr, bsize)    free(ptr)
  1410. X#ifndef major        /* ouch! */
  1411. X#include <sys/types.h>
  1412. X#endif
  1413. SHAR_EOF
  1414. if test 1590 -ne "`wc -c < 'rpc/rpclib/types.h'`"
  1415. then
  1416.     echo shar: "error transmitting 'rpc/rpclib/types.h'" '(should have been 1590 characters)'
  1417. fi
  1418. chmod 444 'rpc/rpclib/types.h'
  1419. fi
  1420. echo shar: "extracting 'rpc/rpclib/xdr.h'" '(8866 characters)'
  1421. if test -f 'rpc/rpclib/xdr.h'
  1422. then
  1423.     echo shar: "will not over-write existing file 'rpc/rpclib/xdr.h'"
  1424. else
  1425. sed 's/^X//' << \SHAR_EOF > 'rpc/rpclib/xdr.h'
  1426. X/*
  1427. X * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  1428. X * unrestricted use provided that this legend is included on all tape
  1429. X * media and as a part of the software program in whole or part.  Users
  1430. X * may copy or modify Sun RPC without charge, but are not authorized
  1431. X * to license or distribute it to anyone else except as part of a product or
  1432. X * program developed by the user.
  1433. X * 
  1434. X * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  1435. X * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  1436. X * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  1437. X * 
  1438. X * Sun RPC is provided with no support and without any obligation on the
  1439. X * part of Sun Microsystems, Inc. to assist in its use, correction,
  1440. X * modification or enhancement.
  1441. X * 
  1442. X * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  1443. X * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  1444. X * OR ANY PART THEREOF.
  1445. X * 
  1446. X * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  1447. X * or profits or other special, indirect and consequential damages, even if
  1448. X * Sun has been advised of the possibility of such damages.
  1449. X * 
  1450. X * Sun Microsystems, Inc.
  1451. X * 2550 Garcia Avenue
  1452. X * Mountain View, California  94043
  1453. X */
  1454. X/*      @(#)xdr.h 1.1 86/02/03 SMI      */
  1455. X
  1456. X/*
  1457. X * xdr.h, External Data Representation Serialization Routines.
  1458. X *
  1459. X * Copyright (C) 1984, Sun Microsystems, Inc.
  1460. X */
  1461. X
  1462. X/*
  1463. X * XDR provides a conventional way for converting between C data
  1464. X * types and an external bit-string representation.  Library supplied
  1465. X * routines provide for the conversion on built-in C data types.  These
  1466. X * routines and utility routines defined here are used to help implement
  1467. X * a type encode/decode routine for each user-defined type.
  1468. X *
  1469. X * Each data type provides a single procedure which takes two arguments:
  1470. X *
  1471. X *    bool_t
  1472. X *    xdrproc(xdrs, argresp)
  1473. X *        XDR *xdrs;
  1474. X *        <type> *argresp;
  1475. X *
  1476. X * xdrs is an instance of a XDR handle, to which or from which the data
  1477. X * type is to be converted.  argresp is a pointer to the structure to be
  1478. X * converted.  The XDR handle contains an operation field which indicates
  1479. X * which of the operations (ENCODE, DECODE * or FREE) is to be performed.
  1480. X *
  1481. X * XDR_DECODE may allocate space if the pointer argresp is null.  This
  1482. X * data can be freed with the XDR_FREE operation.
  1483. X *
  1484. X * We write only one procedure per data type to make it easy
  1485. X * to keep the encode and decode procedures for a data type consistent.
  1486. X * In many cases the same code performs all operations on a user defined type,
  1487. X * because all the hard work is done in the component type routines.
  1488. X * decode as a series of calls on the nested data types.
  1489. X */
  1490. X
  1491. X/*
  1492. X * Xdr operations.  XDR_ENCODE causes the type to be encoded into the
  1493. X * stream.  XDR_DECODE causes the type to be extracted from the stream.
  1494. X * XDR_FREE can be used to release the space allocated by an XDR_DECODE
  1495. X * request.
  1496. X */
  1497. Xenum xdr_op {
  1498. X    XDR_ENCODE=0,
  1499. X    XDR_DECODE=1,
  1500. X    XDR_FREE=2
  1501. X};
  1502. X
  1503. X/*
  1504. X * This is the number of bytes per unit of external data.
  1505. X */
  1506. X#define BYTES_PER_XDR_UNIT    (4)
  1507. X
  1508. X/*
  1509. X * A xdrproc_t exists for each data type which is to be encoded or decoded.
  1510. X *
  1511. X * The second argument to the xdrproc_t is a pointer to an opaque pointer.
  1512. X * The opaque pointer generally points to a structure of the data type
  1513. X * to be decoded.  If this pointer is 0, then the type routines should
  1514. X * allocate dynamic storage of the appropriate size and return it.
  1515. X * bool_t    (*xdrproc_t)(XDR *, caddr_t *);
  1516. X */
  1517. Xtypedef    bool_t (*xdrproc_t)();
  1518. X
  1519. X/*
  1520. X * The XDR handle.
  1521. X * Contains operation which is being applied to the stream,
  1522. X * an operations vector for the paticular implementation (e.g. see xdr_mem.c),
  1523. X * and two private fields for the use of the particular impelementation.
  1524. X */
  1525. Xtypedef struct {
  1526. X    enum xdr_op    x_op;        /* operation; fast additional param */
  1527. X    struct xdr_ops {
  1528. X        bool_t    (*x_getlong)();    /* get a long from underlying stream */
  1529. X        bool_t    (*x_putlong)();    /* put a long to " */
  1530. X        bool_t    (*x_getbytes)();/* get some bytes from " */
  1531. X        bool_t    (*x_putbytes)();/* put some bytes to " */
  1532. X        u_int    (*x_getpostn)();/* returns bytes off from beginning */
  1533. X        bool_t  (*x_setpostn)();/* lets you reposition the stream */
  1534. X        long *    (*x_inline)();    /* buf quick ptr to buffered data */
  1535. X        void    (*x_destroy)();    /* free privates of this xdr_stream */
  1536. X    } *x_ops;
  1537. X    caddr_t     x_public;    /* users' data */
  1538. X    caddr_t        x_private;    /* pointer to private data */
  1539. X    caddr_t     x_base;        /* private used for position info */
  1540. X    int        x_handy;    /* extra private word */
  1541. X} XDR;
  1542. X
  1543. X/*
  1544. X * Operations defined on a XDR handle
  1545. X *
  1546. X * XDR        *xdrs;
  1547. X * long        *longp;
  1548. X * caddr_t     addr;
  1549. X * u_int     len;
  1550. X * u_int     pos;
  1551. X */
  1552. X#define XDR_GETLONG(xdrs, longp)            \
  1553. X    (*(xdrs)->x_ops->x_getlong)(xdrs, longp)
  1554. X#define xdr_getlong(xdrs, longp)            \
  1555. X    (*(xdrs)->x_ops->x_getlong)(xdrs, longp)
  1556. X
  1557. X#define XDR_PUTLONG(xdrs, longp)            \
  1558. X    (*(xdrs)->x_ops->x_putlong)(xdrs, longp)
  1559. X#define xdr_putlong(xdrs, longp)            \
  1560. X    (*(xdrs)->x_ops->x_putlong)(xdrs, longp)
  1561. X
  1562. X#define XDR_GETBYTES(xdrs, addr, len)            \
  1563. X    (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
  1564. X#define xdr_getbytes(xdrs, addr, len)            \
  1565. X    (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
  1566. X
  1567. X#define XDR_PUTBYTES(xdrs, addr, len)            \
  1568. X    (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
  1569. X#define xdr_putbytes(xdrs, addr, len)            \
  1570. X    (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
  1571. X
  1572. X#define XDR_GETPOS(xdrs)                \
  1573. X    (*(xdrs)->x_ops->x_getpostn)(xdrs)
  1574. X#define xdr_getpos(xdrs)                \
  1575. X    (*(xdrs)->x_ops->x_getpostn)(xdrs)
  1576. X
  1577. X#define XDR_SETPOS(xdrs, pos)                \
  1578. X    (*(xdrs)->x_ops->x_setpostn)(xdrs, pos)
  1579. X#define xdr_setpos(xdrs, pos)                \
  1580. X    (*(xdrs)->x_ops->x_setpostn)(xdrs, pos)
  1581. X
  1582. X#define    XDR_INLINE(xdrs, len)                \
  1583. X    (*(xdrs)->x_ops->x_inline)(xdrs, len)
  1584. X#define    xdr_inline(xdrs, len)                \
  1585. X    (*(xdrs)->x_ops->x_inline)(xdrs, len)
  1586. X
  1587. X#define    XDR_DESTROY(xdrs)                \
  1588. X    if ((xdrs)->x_ops->x_destroy)             \
  1589. X        (*(xdrs)->x_ops->x_destroy)(xdrs)
  1590. X#define    xdr_destroy(xdrs)                \
  1591. X    if ((xdrs)->x_ops->x_destroy)             \
  1592. X        (*(xdrs)->x_ops->x_destroy)(xdrs)
  1593. X
  1594. X/*
  1595. X * Support struct for discriminated unions.
  1596. X * You create an array of xdrdiscrim structures, terminated with
  1597. X * a entry with a null procedure pointer.  The xdr_union routine gets
  1598. X * the discriminant value and then searches the array of structures
  1599. X * for a matching value.  If a match is found the associated xdr routine
  1600. X * is called to handle that part of the union.  If there is
  1601. X * no match, then a default routine may be called.
  1602. X * If there is no match and no default routine it is an error.
  1603. X */
  1604. X#define NULL_xdrproc_t ((xdrproc_t)0)
  1605. Xstruct xdr_discrim {
  1606. X    int    value;
  1607. X    xdrproc_t proc;
  1608. X};
  1609. X
  1610. X/*
  1611. X * In-line routines for fast encode/decode of primitve data types.
  1612. X * Caveat emptor: these use single memory cycles to get the
  1613. X * data from the underlying buffer, and will fail to operate
  1614. X * properly if the data is not aligned.  The standard way to use these
  1615. X * is to say:
  1616. X *    if ((buf = XDR_INLINE(xdrs, count)) == NULL)
  1617. X *        return (FALSE);
  1618. X *    <<< macro calls >>>
  1619. X * where ``count'' is the number of bytes of data occupied
  1620. X * by the primitive data types.
  1621. X *
  1622. X * N.B. and frozen for all time: each data type here uses 4 bytes
  1623. X * of external representation.
  1624. X */
  1625. X#define IXDR_GET_LONG(buf)        ntohl(*buf++)
  1626. X#define IXDR_PUT_LONG(buf, v)        (*buf++ = htonl(v))
  1627. X
  1628. X#define IXDR_GET_BOOL(buf)        ((bool_t)IXDR_GET_LONG(buf))
  1629. X#define IXDR_GET_ENUM(buf, t)        ((t)IXDR_GET_LONG(buf))
  1630. X#define IXDR_GET_U_LONG(buf)        ((u_long)IXDR_GET_LONG(buf))
  1631. X#define IXDR_GET_SHORT(buf)        ((short)IXDR_GET_LONG(buf))
  1632. X#define IXDR_GET_U_SHORT(buf)        ((u_short)IXDR_GET_LONG(buf))
  1633. X
  1634. X#define IXDR_PUT_BOOL(buf, v)        IXDR_PUT_LONG((buf), ((long)(v)))
  1635. X#define IXDR_PUT_ENUM(buf, v)        IXDR_PUT_LONG((buf), ((long)(v)))
  1636. X#define IXDR_PUT_U_LONG(buf, v)        IXDR_PUT_LONG((buf), ((long)(v)))
  1637. X#define IXDR_PUT_SHORT(buf, v)        IXDR_PUT_LONG((buf), ((long)(v)))
  1638. X#define IXDR_PUT_U_SHORT(buf, v)    IXDR_PUT_LONG((buf), ((long)(v)))
  1639. X
  1640. X/*
  1641. X * These are the "generic" xdr routines.
  1642. X */
  1643. Xextern bool_t    xdr_void();
  1644. Xextern bool_t    xdr_int();
  1645. Xextern bool_t    xdr_u_int();
  1646. Xextern bool_t    xdr_long();
  1647. Xextern bool_t    xdr_u_long();
  1648. Xextern bool_t    xdr_short();
  1649. Xextern bool_t    xdr_u_short();
  1650. Xextern bool_t    xdr_bool();
  1651. Xextern bool_t    xdr_enum();
  1652. Xextern bool_t    xdr_array();
  1653. Xextern bool_t    xdr_bytes();
  1654. Xextern bool_t    xdr_opaque();
  1655. Xextern bool_t    xdr_string();
  1656. Xextern bool_t    xdr_union();
  1657. Xextern bool_t    xdr_float();
  1658. Xextern bool_t    xdr_double();
  1659. Xextern bool_t    xdr_reference();
  1660. Xextern bool_t    xdr_wrapstring();
  1661. X
  1662. X/*
  1663. X * These are the public routines for the various implementations of
  1664. X * xdr streams.
  1665. X */
  1666. Xextern void   xdrmem_create();        /* XDR using memory buffers */
  1667. Xextern void   xdrstdio_create();    /* XDR using stdio library */
  1668. Xextern void   xdrrec_create();        /* XDR pseudo records for tcp */
  1669. Xextern bool_t xdrrec_endofrecord();    /* make end of xdr record */
  1670. Xextern bool_t xdrrec_skiprecord();    /* move to begining of next record */
  1671. Xextern bool_t xdrrec_eof();        /* true iff no more input */
  1672. SHAR_EOF
  1673. if test 8866 -ne "`wc -c < 'rpc/rpclib/xdr.h'`"
  1674. then
  1675.     echo shar: "error transmitting 'rpc/rpclib/xdr.h'" '(should have been 8866 characters)'
  1676. fi
  1677. chmod 444 'rpc/rpclib/xdr.h'
  1678. fi
  1679. exit 0
  1680. #    End of shell archive
  1681.